package com.lotter.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lotter.service.UserService;

/**
 * 登录controller ClassName: LoginController <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2016年5月24日 下午3:15:19 <br/>
 *
 * @author panguixiang
 * @version
 */
@Controller
@RequestMapping("/user")
public class UserController {

	@Autowired
	private UserService userService;

	@RequestMapping(value = "page", method = RequestMethod.GET)
	public String userlist(String jspname) {
		return jspname;
	}
	
	@RequestMapping(value = "hoursenews", method = RequestMethod.GET)
	public String hoursenews(Long uid,Model model) {
		model.addAttribute("uid", uid);
		return "user/hoursenewlist";
	}

	/**
	 * 用户列表
	 * @param mobile
	 * @param page
	 * @param rows
	 * @return
	 */
	@ResponseBody
	@RequestMapping("userlist")
	public Map<String, Object> pageList(@RequestParam(value="mobile",required=false) String mobile,
			@RequestParam(value="page",required=false) Integer page,
    		@RequestParam(value="rows",required=false) Integer rows) {
		Map<String, Object> result = new HashMap<String, Object>();
		return userService.usrelistPage(mobile, page, rows, result);
	}

	/**
	 * 房主列表
	 * @param mobile
	 * @param page
	 * @param rows
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "hourselistPage")
	public Map<String, Object> hourselistPage(@RequestParam(value="mobile",required=false) String mobile, 
			@RequestParam(value="page",required=false) Integer page,
    		@RequestParam(value="rows",required=false) Integer rows) {
		Map<String, Object> result = new HashMap<String, Object>();
		return userService.hourselistPage(mobile, page, rows, result);
	}
	

	@ResponseBody
	@RequestMapping(value = "hoursercheckPage")
	public Map<String, Object> hoursercheckPage(
			@RequestParam(value="mobile",required=false) String mobile,
			@RequestParam(value="page",required=false) Integer page,
    		@RequestParam(value="rows",required=false) Integer rows) {
		Map<String, Object> result = new HashMap<String, Object>();
		return userService.hoursercheckPage(mobile,page, rows, result);
	}

	@ResponseBody
	@RequestMapping(value = "hoursenewsPage")
	public Map<String, Object> hoursenewsPage(
			@RequestParam(value="uid",required=true) Long uid, 
			@RequestParam(value="page",required=false) Integer page,
    		@RequestParam(value="rows",required=false) Integer rows) {
		Map<String, Object> result = new HashMap<String, Object>();
		return userService.hoursenewsPage(uid, page, rows, result);
	}
	
	@ResponseBody
	@RequestMapping(value = "winPayFlowVosPage")
	public Map<String, Object> winPayFlowVosPage(
			@RequestParam(value="startdatestr",required=false) String startdatestr, 
    		@RequestParam(value="enddatestr",required=false) String enddatestr,
    		@RequestParam(value="page",required=false) Integer page,
    		@RequestParam(value="rows",required=false) Integer rows) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			return userService.winPayFlowVosPage(startdatestr,enddatestr, page, rows, result);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	
	
	@ResponseBody
	@RequestMapping(value = "updateuserhourse")
	public void updateuserhourse(@RequestParam("id") Long id,@RequestParam("utype") Integer utype) {
		userService.updateuserhourse(id, utype);
	}

	@ResponseBody
	@RequestMapping(value = "deleteHoursernew")
	public void deleteHoursernew(Long id) {
		userService.deleteHoursernew(id);
	}

}
